{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Distributed Variational Quantum Eigensolver Based on Schmidt Decomposition\n",
    "*Copyright (c) 2021 Institute for Quantum Computing, Baidu Inc. All Rights Reserved.*"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "tags": []
   },
   "source": [
    "## Overview\n",
    "\n",
    "Retrieving ground state information of a Hamiltonian is amongst the essential questions in physics and chemistry. Currently, it is widely believed that quantum computers are advantageous in solving this kind of problem. As one of the promising algorithms to demonstrate quantum supremacy in the near term, [Variational Quantum Eigensolver (VQE)](https://qml.baidu.com/tutorials/quantum-simulation/variational-quantum-eigensolver.html)\n",
    "enables the study of quantum chemistry on Noisy Intermediate-Scale Quantum (NISQ) devices. However, various technical limitations still exist on current NISQ hardware, forbidding the deployment of large-scale quantum algorithms. For example, limited by the number of available qubits, researchers have not been able to simulate realistic large molecules with high precision. To overcome this barrier, researchers have proposed a wide range of distributed strategies [1-3]. In this tutorial, we take the distributed VQE based on Schmidt decomposition, proposed in [4], as an example to demonstrate how to implement distributed quantum algorithms using Paddle Quantum."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Schmidt Decomposition\n",
    "We start with the following trivial decomposition for any pure state $|\\psi\\rangle$ of a composite system $AB$:\n",
    "\n",
    "$$\n",
    "|\\psi\\rangle=\\sum_{ij}a_{ij}|i\\rangle\\otimes|j\\rangle,\n",
    "\\tag{1}\n",
    "$$\n",
    "\n",
    "where $|i\\rangle$ and $|j\\rangle$ are computational bases of subsystems $A$ and $B$ respectively, and $a_{ij}$ are elements of some complex matrix $a$. Then, we apply [singular value decomposition (SVD)](https://en.wikipedia.org/wiki/Singular_value_decomposition)\n",
    "on $a$, i.e., $a = udv$ with $u,v$ being unitary and $d$ diagonal. Hence, $a_{ij}=\\sum_ku_{ik}d_{kk}v_{kj}$. \n",
    "\n",
    "By defining\n",
    "\n",
    "$$\n",
    "\\begin{aligned}\n",
    "|k_A\\rangle\\equiv & \\sum_iu_{ik}|i\\rangle=u|k\\rangle,\\\\\n",
    "|k_B\\rangle\\equiv & \\sum_jv_{kj}|j\\rangle=v^T|k\\rangle,\\\\\n",
    "\\lambda_k\\equiv & d_{kk},\n",
    "\\end{aligned}\n",
    "\\tag{2}\n",
    "$$\n",
    "\n",
    "we may rewrite Eq. (1) as\n",
    "\n",
    "$$\n",
    "\\begin{aligned}\n",
    "    |\\psi\\rangle  &= \\sum_{ijk}u_{ik}d_{kk}v_{kj}|i\\rangle\\otimes|j\\rangle \\\\\n",
    "                &= \\sum_{k}\\lambda_{k}\\Big(\\sum_iu_{ik}|i\\rangle\\Big)\\otimes\\Big(\\sum_jv_{kj}|j\\rangle\\Big) \\\\\n",
    "                &=\\sum_{k}\\lambda_k(u|k\\rangle\\otimes v^T|k\\rangle)\\\\\n",
    "                &=\\sum_{k}\\lambda_k|k_A\\rangle\\otimes|k_B\\rangle.\n",
    "\\end{aligned}\n",
    "\\tag{3}\n",
    "$$\n",
    "\n",
    "The decomposition of $|\\psi\\rangle$ into the form of $\\sum_k\\lambda_k|k_A\\rangle\\otimes|k_B\\rangle$ is known as its ***Schmidt decomposition*** [5], with $\\{\\lambda_k\\}_k$ called the *Schmidt coefficients* and the number of non-zero $\\lambda_k$'s its *Schmidt rank*. In fact, the property of SVD also guarantees that $\\lambda_k\\in\\mathbb{R}^+$ and $\\sum_k\\lambda_k^2=1$. "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "tags": []
   },
   "source": [
    "## Distributed VQE Based on Schmidt Decomposition\n",
    "\n",
    "As a variation of the standard VQE [6], the distributed VQE also seeks to solve the ground state and its energy of an $N$-qubit Hamiltonian $\\hat{H}=\\sum_tc_t\\hat{H}_t^{(A)}\\otimes\\hat{H}_t^{(B)}$， where $\\hat{H}_t^{(A)},\\hat{H}_t^{(B)}$ are Hamiltonian terms on subsystems $A,B$ respectively (we have assumed that $A$, $B$ both have $N/2$ qubits).\n",
    "\n",
    "To start with, we write the trial wave function as\n",
    "\n",
    "$$\n",
    "|\\psi\\rangle\\equiv\\sum_{k=1}^S\\lambda_k\\Big(U(\\boldsymbol{\\theta})|k\\rangle\\Big)\\otimes\\Big(V(\\boldsymbol{\\phi})|k\\rangle\\Big),\n",
    "\\tag{4}\n",
    "$$\n",
    "\n",
    "for some $\\boldsymbol{\\lambda}\\equiv(\\lambda_1, \\lambda_2,...,\\lambda_S)^T$ and $1\\leq S\\leq 2^{N/2}$ a user-defined constant. According to Schmidt decomposition, the target ground state also has the form of Eq. (4) and hence can be approximated with high precision by choosing appropriate parameters $\\boldsymbol{\\lambda}, \\boldsymbol{\\theta}$ and $\\boldsymbol{\\phi}$.\n",
    "\n",
    "Now, for all $i,j=1,...,S$, we evaluate the following terms on an $N/2$-qubit quantum computer:\n",
    "\n",
    "$$\n",
    "\\begin{aligned}\n",
    "E_{ijt}^A(\\boldsymbol{\\theta}) &\\equiv \\langle i|U^\\dagger(\\boldsymbol{\\theta}) \\hat{H}_t^{(A)} U(\\boldsymbol{\\theta})|j\\rangle,\\\\\n",
    "E_{ijt}^B(\\boldsymbol{\\phi}) &\\equiv \\langle i|V^\\dagger(\\boldsymbol{\\phi}) \\hat{H}_t^{(B)} V(\\boldsymbol{\\phi}))|j\\rangle.\n",
    "\\end{aligned}\n",
    "\\tag{5}\n",
    "$$\n",
    "\n",
    "Then, on a classical computer, we construct an $S\\times S$ dimensional matrix $M(\\boldsymbol{\\theta},\\boldsymbol{\\phi})$ according to\n",
    "\n",
    "$$\n",
    "[M(\\boldsymbol{\\theta},\\boldsymbol{\\phi})]_{ij}\\equiv\\sum_tc_tE_{ijt}^A(\\boldsymbol{\\theta})E_{ijt}^B(\\boldsymbol{\\phi}).\n",
    "\\tag{6}\n",
    "$$\n",
    "\n",
    "In this way, the target ground state energy can be written as  \n",
    "$$\n",
    "\\begin{aligned}\n",
    "E_{tar}   &= \\min_{\\boldsymbol{\\lambda}, \\boldsymbol{\\theta}, \\boldsymbol{\\phi}} \\langle{\\psi}|\\hat{H}|\\psi\\rangle \\\\\n",
    "    &= \\min_{\\boldsymbol{\\lambda}, \\boldsymbol{\\theta}, \\boldsymbol{\\phi}}\\Big(\\sum_{i,j=1}^S\\lambda_i\\lambda_j[M(\\boldsymbol{\\theta},\\boldsymbol{\\phi})]_{ij}\\Big)\\\\\n",
    "    &= \\min_{\\boldsymbol{\\theta}, \\boldsymbol{\\phi}} E(\\boldsymbol{\\theta},\\boldsymbol{\\phi}),\n",
    "\\end{aligned}\n",
    "\\tag{7}\n",
    "$$\n",
    "\n",
    "where $E(\\boldsymbol{\\theta},\\boldsymbol{\\phi})\\equiv\\min_{\\boldsymbol{\\lambda}} \\boldsymbol{\\lambda}^T M(\\boldsymbol{\\theta},\\boldsymbol{\\phi})\\boldsymbol{\\lambda}$. By linear algebra, we see that $E(\\boldsymbol{\\theta},\\boldsymbol{\\phi})$ is exactly the minimal eigenvalue of $M(\\boldsymbol{\\theta},\\boldsymbol{\\phi})$, which can be solved using classical algorithms.\n",
    "\n",
    "Finally, we repeat the whole process and minimize $E(\\boldsymbol{\\theta},\\boldsymbol{\\phi})$ to approximate $E_{tar}$ using gradient-based optimization methods."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "tags": []
   },
   "source": [
    "## Paddle Quantum implementation\n",
    "\n",
    "First of all, we import necessary packages. Please make sure that you have *PaddlePaddle* >= 2.2.0 and *Paddle Quantum* >= 2.2.0, as we will use some of their latest features."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import time\n",
    "import numpy as np\n",
    "from matplotlib import pyplot as plt\n",
    "\n",
    "import paddle\n",
    "import paddle_quantum\n",
    "from paddle_quantum.ansatz import Circuit\n",
    "from paddle_quantum.qinfo import pauli_str_to_matrix, schmidt_decompose\n",
    "import warnings\n",
    "\n",
    "warnings.filterwarnings(\"ignore\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Define some global constants:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "N = 10      # Number of qubits\n",
    "SEED = 16   # Fix a random seed\n",
    "ITR = 100   # Set the number of learning iterations\n",
    "LR = 0.1    # Set the learning rate\n",
    "D = 3       # Set the depth for QNN"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The following function classically calculates the ground state information (the energy and the Schmidt rank of the ground state) of a Hamiltonian $H$, which we will use as the ground truth to benchmark our quantum models."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "def get_ground_state_info(H):\n",
    "\n",
    "    # Calculate the eigenvalues and eigenvectors of H\n",
    "    vals, vecs = paddle.linalg.eigh(H)\n",
    "    # Retrieve the ground state\n",
    "    ground_state = paddle_quantum.State(vecs[:, 0])\n",
    "    # Retrieve the ground state energy\n",
    "    ground_state_energy = vals.tolist()[0]\n",
    "    print(f'The ground state energy is {ground_state_energy:.5f} Ha.')\n",
    "    # Run Schmidt decomposition on the ground state.\n",
    "    l, _, _ = schmidt_decompose(ground_state)\n",
    "    print(f'Schmidt rank of the ground state is {l.size}.')\n",
    "\n",
    "    return ground_state_energy"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now, we generate a Hamiltonian and calculate its ground state information."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The ground state energy is -0.99783 Ha.\n",
      "Schmidt rank of the ground state is 32.\n"
     ]
    }
   ],
   "source": [
    "# Fix a random seed\n",
    "np.random.seed(SEED)\n",
    "\n",
    "# Hard code a random a Hamiltonian\n",
    "coefs = [-0.8886258, 0.453882]\n",
    "pauli_str = ['x0,z1,z2,z4,x5,y6,y7,x8,x9', 'y0,x1,x2,x3,y4,x5,z6,z7,y8,x9']\n",
    "pauli_str_A = ['x0,z1,z2,z4', 'y0,x1,x2,x3,y4']     # pauli substring for system A\n",
    "pauli_str_B = ['x0,y1,y2,x3,x4', 'x0,z1,z2,y3,x4']  # pauli substring for system B\n",
    "\n",
    "# Convert relavent object into Tensor form\n",
    "H_mtr = paddle.to_tensor(pauli_str_to_matrix(zip(coefs, pauli_str), n=N))\n",
    "coefs = paddle.to_tensor(coefs)\n",
    "H_A = [pauli_str_to_matrix([[1., pstr]], n=N//2) for pstr in pauli_str_A]\n",
    "H_A = paddle.to_tensor(np.stack(H_A))\n",
    "H_B = [pauli_str_to_matrix([[1., pstr]], n=N-N//2) for pstr in pauli_str_B]\n",
    "H_B = paddle.to_tensor(np.stack(H_B))\n",
    "\n",
    "# calculate the ground state information\n",
    "ground_state_energy = get_ground_state_info(H_mtr)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now that we have prepared a Hamiltonian, we may build a distributed VQE to solve it."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Construct parameterized circuit\n",
    "def U_cir(N, D):\n",
    "    \n",
    "    cir = Circuit(N)  # Initialize an N-qubit-width circuit\n",
    "    cir.complex_entangled_layer('full', N, D)   # Add quantum gates\n",
    "    return cir  \n",
    "\n",
    "# Apply a parameterized circuit on the conputational bases\n",
    "# and return a tensor of shape [2**N, num_states]\n",
    "def output_states(num_states, N, cir):\n",
    "    # Create num_states-many computational bases\n",
    "    basis = paddle.eye(2**N, num_states)\n",
    "    \n",
    "    # Acquire a matrix of the parameterized circuit\n",
    "    U = cir.unitary_matrix()\n",
    "    \n",
    "    # Apply the parameterized circuit on these bases\n",
    "    vec = U @ basis                         \n",
    "    \n",
    "    return vec"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The code below is core to this tutorial. Please compare them with the formulae given in the beginning section and make sure that they are well understood."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Construct the distributed model\n",
    "class DistributedVQE(paddle.nn.Layer):\n",
    "    def __init__(self, N, D, S):\n",
    "        super().__init__()\n",
    "        paddle.seed(SEED)\n",
    "\n",
    "        self.S = S  # Define constant S\n",
    "        self.N = N\n",
    "        self.cir = [U_cir(N//2, D), U_cir(N - N//2, D)]\n",
    "        \n",
    "    # The core logic of distributed VQE\n",
    "    def forward(self):\n",
    "        # Obtain U|k> and V|k> for subsystems A and B respectively \n",
    "        vec_A = output_states(self.S, self.N//2, self.cir[0])\n",
    "        vec_B = output_states(self.S, self.N - self.N//2, self.cir[1])\n",
    "        \n",
    "        # Calculate tensor E_A, E_B, which have elements E_{ijt}^A and E_{ijt}^B, as per defined in above\n",
    "        E_A = vec_A.conj().t() @ H_A @ vec_A\n",
    "        E_B = vec_B.conj().t() @ H_B @ vec_B\n",
    "        M = (coefs.reshape([-1, 1, 1]) * E_A * E_B).sum(0)\n",
    "\n",
    "        # Find the minimal eigenvalue of M\n",
    "        eigval = paddle.linalg.eigvalsh(M)\n",
    "        loss = eigval[0]\n",
    "        \n",
    "        return loss"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Define training function."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "def train(model):\n",
    "    start_time = time.time()    # To calculate the running time of this function\n",
    "    params = sum([cir.parameters() for cir in model.cir], [])\n",
    "    # We will use Adam, a gradient-based optimizer to optimize theta and phi\n",
    "    opt = paddle.optimizer.Adam(learning_rate=LR, parameters=params)\n",
    "    summary_loss = []           # Save loss history\n",
    "\n",
    "    # Optimization iteration\n",
    "    for itr in range(ITR):\n",
    "        # Forward propagation to calculates the loss function\n",
    "        loss = model()\n",
    "        # Backward propagation to optimize the loss function\n",
    "        loss.backward()\n",
    "        opt.minimize(loss)\n",
    "        opt.clear_grad()\n",
    "        # Update optimization result\n",
    "        summary_loss.append(loss.numpy())\n",
    "        # Print itermediary result\n",
    "        if (itr+1) % 20 == 0:\n",
    "            print(f\"iter: {itr+1}, loss: {loss.tolist()[0]: .4f} Ha\")\n",
    "\n",
    "    print(f'Ground truth is  {ground_state_energy:.4f} Ha')\n",
    "    print(f'Training took {time.time() - start_time:.2f}s')\n",
    "    \n",
    "    plt.plot(list(range(ITR)), summary_loss, color='r', label='loss')\n",
    "    plt.hlines(y=ground_state_energy, xmin=0, xmax=ITR, linestyle=':',  label='ground truth')\n",
    "    plt.legend()\n",
    "    plt.title(f'Loss for {type(model).__name__} on a {N}-qubit Hamiltonian')\n",
    "    plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now, we are ready to instantiate the model and train it!"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "iter: 20, loss: -0.9244 Ha\n",
      "iter: 40, loss: -0.9906 Ha\n",
      "iter: 60, loss: -0.9968 Ha\n",
      "iter: 80, loss: -0.9977 Ha\n",
      "iter: 100, loss: -0.9978 Ha\n",
      "Ground truth is  -0.9978 Ha\n",
      "Training took 7.24s\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXwAAAEICAYAAABcVE8dAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAAAuCElEQVR4nO3deZgU1dn38e89CwzLsC+KgCwigiCoA6ICEsVEjQLGGDWLkESNT5Y3q8bE90k0JsYn+ibG5IlLTBR3jBoDLnEhLhhxGRREAUUIyM6AbMMAs93vH6cGm6GHWXpmauj+fa6rr+7qqq5zV5/qu0+fOl1l7o6IiKS/rLgDEBGR5qGELyKSIZTwRUQyhBK+iEiGUMIXEckQSvgiIhlCCb8JmFkbM5tlZtvM7G/NWG6xmQ1opHX91MzujB73MzM3s5zGWHcDYrnGzO6Lo2wJzGyCma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XbXPa1nOCmup1JnBxNFpnDLAtoeunftw9rW6Ea+l+ACwDro47nibaxrGEn3vvAPOj21mEPu3ZwFLgeaBL3LE20fZPAJ6IHg8A3gA+BP4GtI47vkbe1pFAYVTXjwOd072egWuBJcC7wL1A63SrZ+BBwjGKMsIvua/XVK+AEUYfLgMWEkYwNahcnVpBRCRDpFuXjoiI1EAJX0QkQyjhi4hkCCV8EZEMoYQvIpIhlPBFRDKEEr6ISIb4/5Xpoi3GL8rEAAAAAElFTkSuQmCC",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Note that we manually set S = 4 as the Hamiltonian we just created interacts weakly across the subsystems.\n",
    "# (See the Conclusion section for further description)\n",
    "vqe = DistributedVQE(N, D, S=4)\n",
    "train(vqe)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We have plotted the actual ground state energy as a dotted line in the figure above. We see that the loss curve converges to the dotted line, meaning that our distributed VQE successfully found the ground state energy of the Hamiltonian. However, to properly evaluate our model, we need to compare it with the standard VQE, which we build below:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "class StandardVQE(paddle.nn.Layer):\n",
    "    def __init__(self, N, D, S):\n",
    "        super().__init__()\n",
    "        paddle.seed(SEED)\n",
    "        self.N = N\n",
    "        self.S = S\n",
    "        self.cir = [U_cir(N, D)]\n",
    "\n",
    "    def forward(self):\n",
    "        vec = output_states(self.S, self.N, self.cir[0])\n",
    "        loss = vec.conj().t() @ H_mtr @ vec\n",
    "        return loss.cast('float64').flatten()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Instantiate and train the StandardVQE."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "iter: 20, loss: -0.8365 Ha\n",
      "iter: 40, loss: -0.9852 Ha\n",
      "iter: 60, loss: -0.9958 Ha\n",
      "iter: 80, loss: -0.9975 Ha\n",
      "iter: 100, loss: -0.9978 Ha\n",
      "Ground truth is  -0.9978 Ha\n",
      "Training took 1278.13s\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXwAAAEICAYAAABcVE8dAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAAAuSklEQVR4nO3deXwU9f3H8dcnFxHCnQByJkBEkEsNeFQQC9arotYDrwpapLbVtlRrrdZWq22ttD+1v7Ye9UL9qXgr1mqVqmgLlaCgCCJySTjDFcIRcn1/f3wnuAmbc5Nssvt+Ph772J2d78x8Zmf2s9/9zndmzDmHiIjEvoRoByAiIs1DCV9EJE4o4YuIxAklfBGROKGELyISJ5TwRUTihBJ+MzKzQ8xstpkVmNmz0Y4nUmb2qJnd3ojze8fMpjbW/KT+zOwWM3uihvGfmtm45ouofszsPjO7OXg9zszymmg5Y8xseVPMuynFZcI3szVmNiEKiz4P6A50dc6d3xgzNLMbzWy1me02szwzmxUyrlUmUDM71sz2mFlamHEfmdnVwes2ZvY7M/vSzPaZ2Qozu87MLKT8O2ZWFHw+FY/Zzbk+tTGzFDN7LtgvXdWEat7vzWxb8Ph96Do2J+fcEc65d4K4avxxCMoc9F0zsylm9n4TxXeVc+62usYSwXLec84Naox5Nae4TPhR1A/43DlXWt8JzSwpzHuTgW8DE5xzaUAOMCfiKJtYkMCq3fecc/OBPPwPZOh0Q4EhwFPBW88C44HTgfb4z+K7wB+rzPJq51xayOPMxlmTRvU+cCmwKcy4acDZwAhgOHAmfj1F6sc5F3cPYA0+SVZ9vw1wN7AheNwNtAnGpQOvAjuB7cB7QEIw7mfAeqAQWA6MDzPvW4FioATYDXwH/4P7C2AtsAV4DO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DoXNnNeuISKO45ZZb+MMf/nDQ+y+99BJLly6t9/zWrFnDk08+eWD40Ucf5eqrr44oxnDiI+EnJMCYMarhi8SR0tLSZl9mTQm/pniqJvymEh8JH3w7/sqVuka+SAy47bbbGDRoECeccAIXXXTRgdr2uHHj+PGPf0xOTg733HMPc+bM4cgjj2TYsGFcccUV7N+/H4DMzEy2bt0KQG5uLuPGjQN8zf2KK65g3Lhx9O/fnz/96U8Hlvmb3/yGww47jBNOOIHly5cfFNN//vMfXnnlFX76058ycuRIVq5ceVA8U6ZM4bnnnjswTcWNXG644Qbee+89Ro4ceeCyzRs2bODUU08lOzub66+/vlE+t/hK+KBmHZFGNun+eTyb6296V1JWzqT75/HiR3kA7CsuY9L985i9eAMAu4pKmHT/PF5fshGA7XuKmXT/PN5auhmALYW135R7wYIFPP/88yxevJh//OMfVD0jv7i4mNzcXH7wgx8wZcoUZs2axSeffEJpaSn31uHquZ999hlvvPEGH3zwAbfeeislJSUsXLiQp59+mkWLFvHaa6+xYMGCg6Y7/vjjmThxIjNmzGDRokUMGDCgUjzXXntttcu84447GDNmDIsWLWL69OkALFq06EDss2bNYt26ddVOX1fxk/BHjIA2bWDhwmhHIiIR+Pe//81ZZ51Famoq7du358wzz6w0ftKkSQAsX76crKwsDjvsMAAmT57M3DpU+M444wzatGlDeno63bp1Y/Pmzbz33nucc845tG3blg4dOjBx4sRa51M1nvoaP348HTt2JDU1lSFDhrB27doGzSdUbF88LVRSEmRmqmumSCOb9d3jDrxOTkyoNHxISmKl4Q6pyZWGu7RLqTTcrX3klzFv165drWWSkpIOXEStqKjyv4o2bdoceJ2YmBjxsYDQeEKXW15eTnFxcbXTNXYcEE81fFDCF4kBX/va15g9ezZFRUXs3r2bV199NWy5QYMGsWbNGr744gsAHn/8cU4MmnYzMzNZGPzbf/7552td5tixY3nppZfYt28fhYWFzJ49O2y59u3bU1hYWO18Qpf7yiuvUFJSUqfpGkt8JfysLFi9OtpRiEgERo0axcSJExk+fDinnXYaw4YNo2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pnMP8Lpz7nBgBH7dY3Y7m1kv4IdAjnNuKJCIv4dGrG3nR4FTq7xX3XY9DcgOHtOAexu60JhK+ITcMN05VwxU3DA9pjjnNjrnPgxeF+KTQC/8us4Mis0Ezo5KgE3EzHoDZwAPBsMGfB14LigSU+tsZh2BscBDAM65YufcTmJ8O+Mv236ImSUBbYGNxNh2ds7NBbZXebu67XoW8Jjz5gOdzOzQhiw31hJ+uBum94pSLM3CzDKBI4H/At2dcxuDUZuA7tGKq4ncDVwPlAfDXYGdwU12IPa2dxaQDzwSNGM9aGbtiOHt7JxbD/wB+BKf6AuAhcT2dq5Q3XZttLwWawk/rphZGvA88GPn3K7Qcc73t42ZPrdm9k1gi3NuYbRjaUZJwFHAvc65I4E9VGm+icHt3Blfo80CegLtOLjpI+Y11XaNtYQfNzdMN7NkfLL/P+fcC8Hbmyv+6gXPW6IVXxP4GjDRzNbgm+q+jm/f7hT89YfY2955QJ5z7r/B8HP4H4BY3s4TgNXOuXznXAnwAn7bx/J2rlDddm20vBZrCT8ubpgetF0/BCxzzv1PyKhXgMnB68nAy80dW1Nxzv3cOdfbOZeJ367/cs5dArwNnBcUi7V13gSsM7NBwVvjgaXE8HbGN+Uca2Ztg/28Yp1jdjuHqG67vgJcFvTWORYoCGn6qR/nXEw98PfS/RxYCdwU7XiaaB1PwP/d+xhYFDxOx7dpzwFWAG8BXaIdaxOt/zjg1eB1f+AD4AvgWaBNtONr5HUdCeQG2/oloHOsb2fgVuAzYAnwONAm1rYz8BT+GEUJ/p/cd6rbroDhex+uBD7B92Bq0HJ1aQURkTgRa006IiJSDSV8EZE4oYQvIhInlPBFROKEEr6ISJxQwhcRiRNK+CIiceL/AVGmKYoZJlk+AAAAAElFTkSuQmCC",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "svqe = StandardVQE(N, D, S=1)\n",
    "train(svqe)  # Train the standard VQE "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Interestingly, by comparing the running time of the two models, we find that the distributed model runs 100 times faster than the standard VQE! In fact, this is easy to understand: in a distributed model, we only need to simulate two $N/2$-qubit unitary transformations, which is, of course, much more time- and space-efficient than simulating an $N$-qubit unitary transformation in the standard VQE."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "tags": []
   },
   "source": [
    "## Conclusion\n",
    "\n",
    "In this tutorial, we built a distributed VQE and demonstrated some of its advantages:\n",
    "- The capability of NISQ devices is expanded. Distributed strategies enable the deployment of quantum algorithms which require qubits that exceed the capability of current hardware.\n",
    "- The computation efficiency is improved. For classical simulation of quantum processes, distributed algorithms reduce the dimension of unitary matrices, hence reducing the space and time cost for simulating them.\n",
    "\n",
    "In the meantime, one must note that $S$, as a user-defined constant, plays a key role in the training accuracy and efficiency:\n",
    "- For Hamiltonians which encode weak inter-subsystem interactions, their ground states are weakly entangled across the subsystems [7]. Hence, the Schmidt ranks are small and can be accurately and efficiently simulated by a small $S$. In fact, our example and most physically and chemically interesting Hamiltonians fall into this category.\n",
    "- In contrast, for Hamiltonians which encode strong inter-subsystem interactions, their ground states are strongly entangled. Hence, a large $S$ may be required. But anyway, $S$ is upper-bounded by $2^{N/2}$ and thus the dimension of $M$ is upper-bounded by $2^{N/2}\\times2^{N/2}$, which is still much smaller than the dimension of the initial Hamiltonian ($2^{N}\\times 2^{N}$). Consequently, the efficiency of this algorithm is always better than the purely classical simulation."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "jp-MarkdownHeadingCollapsed": true,
    "tags": []
   },
   "source": [
    "_______\n",
    "\n",
    "# References\n",
    "\n",
    "[1] Fujii, Keisuke, et al. \"Deep Variational Quantum Eigensolver: a divide-and-conquer method for solving a larger problem with smaller size quantum computers.\" [arXiv preprint arXiv:2007.10917 (2020)](https://arxiv.org/abs/2007.10917).\n",
    "\n",
    "[2] Zhang, Yu, et al. \"Variational Quantum Eigensolver with Reduced Circuit Complexity.\" [arXiv preprint arXiv:2106.07619(2021)](https://arxiv.org/abs/2106.07619).\n",
    "\n",
    "[3] Peng, Tianyi et al. \"Simulating Large Quantum Circuits On A Small Quantum Computer\". [Physical Review Letters 125.15, (2020): 150504](https://journals.aps.org/prl/abstract/10.1103/PhysRevLett.125.150504).\n",
    "\n",
    "[4] Eddins, Andrew, et al. \"Doubling the size of quantum simulators by entanglement forging.\" [arXiv preprint arXiv:2104.10220 (2021)](https://arxiv.org/abs/2104.10220).\n",
    "\n",
    "[5] Nielsen, Michael A., and Isaac L. Chuang. Quantum Computation and Quantum Information. Cambridge University Press, 2010.\n",
    "\n",
    "[6] Moll, Nikolaj, et al. \"Quantum optimization using variational algorithms on near-term quantum devices.\" [Quantum Science and Technology 3.3 (2018): 030503](https://iopscience.iop.org/article/10.1088/2058-9565/aab822).\n",
    "\n",
    "[7] Khatri, Sumeet, and Mark M. Wilde. \"Principles of quantum communication theory: A modern approach.\" [arXiv preprint arXiv:2011.04672 (2020)](https://arxiv.org/abs/2011.04672)."
   ]
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "9043b12ec77a531919bc05f05830335d23baf822720cbea14b03018197d26545"
  },
  "kernelspec": {
   "display_name": "Python 3.8.0 ('paddle-quantum-dev')",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
